<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body onload='main()'>
    <canvas id='myBox'>如果你看见我，就请更换别的浏览器查看效果</canvas>
    <script>
        function main(){
            let canvas=document.getElementById('myBox');
            if(!canvas){
                console.log(获取元素错误);
                return false
            }
            // 获取上下文
            let ctx=canvas.getContext('2d')
            // 填充颜色
            ctx.fillStyle='rgba(0,0,255,1.0)'
            // 制定矩形的位置
            ctx.fillRect(120,10,50,70);

        }
    </script>
</body>
</html>